home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / SoundInput.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-11  |  9.5 KB  |  234 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        SoundInput.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __SOUNDINPUT__
  18. #define __SOUNDINPUT__
  19.  
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __DIALOGS__
  27. #include <Dialogs.h>
  28. #endif
  29. /*    #include <Errors.h>                                            */
  30. /*    #include <Memory.h>                                            */
  31. /*        #include <MixedMode.h>                                    */
  32. /*    #include <Windows.h>                                        */
  33. /*        #include <Quickdraw.h>                                    */
  34. /*            #include <QuickdrawText.h>                            */
  35. /*        #include <Events.h>                                        */
  36. /*            #include <OSUtils.h>                                */
  37. /*        #include <Controls.h>                                    */
  38. /*            #include <Menus.h>                                    */
  39. /*    #include <TextEdit.h>                                        */
  40.  
  41. #ifndef __FILES__
  42. #include <Files.h>
  43. #endif
  44.  
  45. #ifndef __SOUND__
  46. #include <Sound.h>
  47. #endif
  48.  
  49. #ifdef __cplusplus
  50. extern "C" {
  51. #endif
  52.  
  53. #if GENERATINGPOWERPC
  54. #pragma options align=mac68k
  55. #endif
  56.  
  57. #ifdef __CFM68K__
  58. #pragma lib_export on
  59. #endif
  60.  
  61.  
  62. enum {
  63.     siDeviceIsConnected            = 1,                            /*input device is connected and ready for input*/
  64.     siDeviceNotConnected        = 0,                            /*input device is not connected*/
  65.     siDontKnowIfConnected        = -1,                            /*can't tell if input device is connected*/
  66.     siReadPermission            = 0,                            /*permission passed to SPBOpenDevice*/
  67.     siWritePermission            = 1                                /*permission passed to SPBOpenDevice*/
  68. };
  69.  
  70. enum {
  71. /*Info Selectors for Sound Input Drivers*/
  72.     siDeviceConnected            = 'dcon',                        /*input device connection status*/
  73.     siAGCOnOff                    = 'agc ',                        /*automatic gain control state*/
  74.     siPlayThruOnOff                = 'plth',                        /*playthrough state*/
  75.     siTwosComplementOnOff        = 'twos',                        /*two's complement state*/
  76.     siLevelMeterOnOff            = 'lmet',                        /*level meter state*/
  77.     siRecordingQuality            = 'qual',                        /*recording quality*/
  78.     siVoxRecordInfo                = 'voxr',                        /*VOX record parameters*/
  79.     siVoxStopInfo                = 'voxs',                        /*VOX stop parameters*/
  80.     siNumberChannels            = 'chan',                        /*current number of channels*/
  81.     siSampleSize                = 'ssiz',                        /*current sample size*/
  82.     siSampleRate                = 'srat',                        /*current sample rate*/
  83.     siCompressionType            = 'comp',                        /*current compression type*/
  84.     siCompressionFactor            = 'cmfa',                        /*current compression factor*/
  85.     siCompressionHeader            = 'cmhd',                        /*return compression header*/
  86.     siDeviceName                = 'name',                        /*input device name*/
  87.     siDeviceIcon                = 'icon',                        /*input device icon*/
  88.     siDeviceBufferInfo            = 'dbin',                        /*size of interrupt buffer*/
  89.     siSampleSizeAvailable        = 'ssav',                        /*sample sizes available*/
  90.     siSampleRateAvailable        = 'srav',                        /*sample rates available*/
  91.     siCompressionAvailable        = 'cmav',                        /*compression types available*/
  92.     siChannelAvailable            = 'chav',                        /*number of channels available*/
  93.     siAsync                        = 'asyn',                        /*asynchronous capability*/
  94.     siOptionsDialog                = 'optd',                        /*display options dialog*/
  95.     siContinuous                = 'cont',                        /*continous recording*/
  96.     siActiveChannels            = 'chac',                        /*active channels*/
  97.     siActiveLevels                = 'lmac',                        /*active meter levels*/
  98.     siInputSource                = 'sour',                        /*input source selector*/
  99.     siInputSourceNames            = 'snam',                        /*input source names*/
  100.     siInputGain                    = 'gain',                        /*input gain*/
  101.     siInitializeDriver            = 'init',                        /*reserved for internal use only*/
  102.     siCloseDriver                = 'clos',                        /*reserved for internal use only*/
  103.     siPauseRecording            = 'paus',                        /*reserved for internal use only*/
  104.     siUserInterruptProc            = 'user',                        /*reserved for internal use only*/
  105. /*Qualities*/
  106.     siBestQuality                = 'best',
  107.     siBetterQuality                = 'betr',
  108.     siGoodQuality                = 'good'
  109. };
  110.  
  111. typedef struct SPB SPB, *SPBPtr;
  112.  
  113. /*user procedures called by sound input routines*/
  114. /*
  115.         SIInterruptProcPtr uses register based parameters on the 68k and cannot
  116.         be written in or called from a high-level language without the help of
  117.         mixed mode or assembly glue.
  118.  
  119.         In:
  120.          => inParamPtr      A0.L
  121.          => dataBuffer      A1.L
  122.          => peakAmplitude    D0.W
  123.          => sampleSize      D1.L
  124. */
  125. typedef pascal void (*SICompletionProcPtr)(SPBPtr inParamPtr);
  126.  
  127. #if GENERATINGCFM
  128. typedef UniversalProcPtr SIInterruptUPP;
  129. typedef UniversalProcPtr SICompletionUPP;
  130. #else
  131. typedef Register68kProcPtr SIInterruptUPP;
  132. typedef SICompletionProcPtr SICompletionUPP;
  133. #endif
  134.  
  135. struct SPB {
  136.     long                            inRefNum;                    /*reference number of sound input device*/
  137.     unsigned long                    count;                        /*number of bytes to record*/
  138.     unsigned long                    milliseconds;                /*number of milliseconds to record*/
  139.     unsigned long                    bufferLength;                /*length of buffer in bytes*/
  140.     Ptr                                bufferPtr;                    /*buffer to store sound data in*/
  141.     SICompletionUPP                    completionRoutine;            /*completion routine*/
  142.     SIInterruptUPP                    interruptRoutine;            /*interrupt routine*/
  143.     long                            userLong;                    /*user-defined field*/
  144.     OSErr                            error;                        /*error*/
  145.     long                            unused1;                    /*reserved - must be zero*/
  146. };
  147. extern pascal NumVersion SPBVersion(void)
  148.  FOURWORDINLINE(0x203C, 0x0000, 0x0014, 0xA800);
  149. extern pascal OSErr SndRecord(ModalFilterUPP filterProc, Point corner, OSType quality, SndListHandle *sndHandle)
  150.  FOURWORDINLINE(0x203C, 0x0804, 0x0014, 0xA800);
  151. extern pascal OSErr SndRecordToFile(ModalFilterUPP filterProc, Point corner, OSType quality, short fRefNum)
  152.  FOURWORDINLINE(0x203C, 0x0708, 0x0014, 0xA800);
  153. extern pascal OSErr SPBSignInDevice(short deviceRefNum, ConstStr255Param deviceName)
  154.  FOURWORDINLINE(0x203C, 0x030C, 0x0014, 0xA800);
  155. extern pascal OSErr SPBSignOutDevice(short deviceRefNum)
  156.  FOURWORDINLINE(0x203C, 0x0110, 0x0014, 0xA800);
  157. extern pascal OSErr SPBGetIndexedDevice(short count, Str255 deviceName, Handle *deviceIconHandle)
  158.  FOURWORDINLINE(0x203C, 0x0514, 0x0014, 0xA800);
  159. extern pascal OSErr SPBOpenDevice(ConstStr255Param deviceName, short permission, long *inRefNum)
  160.  FOURWORDINLINE(0x203C, 0x0518, 0x0014, 0xA800);
  161. extern pascal OSErr SPBCloseDevice(long inRefNum)
  162.  FOURWORDINLINE(0x203C, 0x021C, 0x0014, 0xA800);
  163. extern pascal OSErr SPBRecord(SPBPtr inParamPtr, Boolean asynchFlag)
  164.  FOURWORDINLINE(0x203C, 0x0320, 0x0014, 0xA800);
  165. extern pascal OSErr SPBRecordToFile(short fRefNum, SPBPtr inParamPtr, Boolean asynchFlag)
  166.  FOURWORDINLINE(0x203C, 0x0424, 0x0014, 0xA800);
  167. extern pascal OSErr SPBPauseRecording(long inRefNum)
  168.  FOURWORDINLINE(0x203C, 0x0228, 0x0014, 0xA800);
  169. extern pascal OSErr SPBResumeRecording(long inRefNum)
  170.  FOURWORDINLINE(0x203C, 0x022C, 0x0014, 0xA800);
  171. extern pascal OSErr SPBStopRecording(long inRefNum)
  172.  FOURWORDINLINE(0x203C, 0x0230, 0x0014, 0xA800);
  173. extern pascal OSErr SPBGetRecordingStatus(long inRefNum, short *recordingStatus, short *meterLevel, unsigned long *totalSamplesToRecord, unsigned long *numberOfSamplesRecorded, unsigned long *totalMsecsToRecord, unsigned long *numberOfMsecsRecorded)
  174.  FOURWORDINLINE(0x203C, 0x0E34, 0x0014, 0xA800);
  175. extern pascal OSErr SPBGetDeviceInfo(long inRefNum, OSType infoType, void *infoData)
  176.  FOURWORDINLINE(0x203C, 0x0638, 0x0014, 0xA800);
  177. extern pascal OSErr SPBSetDeviceInfo(long inRefNum, OSType infoType, void *infoData)
  178.  FOURWORDINLINE(0x203C, 0x063C, 0x0014, 0xA800);
  179. extern pascal OSErr SPBMillisecondsToBytes(long inRefNum, long *milliseconds)
  180.  FOURWORDINLINE(0x203C, 0x0440, 0x0014, 0xA800);
  181. extern pascal OSErr SPBBytesToMilliseconds(long inRefNum, long *byteCount)
  182.  FOURWORDINLINE(0x203C, 0x0444, 0x0014, 0xA800);
  183. extern pascal OSErr SetupSndHeader(SndListHandle sndHandle, short numChannels, UnsignedFixed sampleRate, short sampleSize, OSType compressionType, short baseNote, unsigned long numBytes, short *headerLen)
  184.  FOURWORDINLINE(0x203C, 0x0D48, 0x0014, 0xA800);
  185. extern pascal OSErr SetupAIFFHeader(short fRefNum, short numChannels, UnsignedFixed sampleRate, short sampleSize, OSType compressionType, unsigned long numBytes, unsigned long numFrames)
  186.  FOURWORDINLINE(0x203C, 0x0B4C, 0x0014, 0xA800);
  187. enum {
  188.     uppSIInterruptProcInfo = kRegisterBased
  189.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA0, SIZE_CODE(sizeof(SPBPtr)))
  190.          | REGISTER_ROUTINE_PARAMETER(2, kRegisterA1, SIZE_CODE(sizeof(Ptr)))
  191.          | REGISTER_ROUTINE_PARAMETER(3, kRegisterD0, SIZE_CODE(sizeof(short)))
  192.          | REGISTER_ROUTINE_PARAMETER(4, kRegisterD1, SIZE_CODE(sizeof(long))),
  193.     uppSICompletionProcInfo = kPascalStackBased
  194.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SPBPtr)))
  195. };
  196.  
  197. #if GENERATINGCFM
  198. #define NewSIInterruptProc(userRoutine)        \
  199.         (SIInterruptUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIInterruptProcInfo, GetCurrentArchitecture())
  200. #define NewSICompletionProc(userRoutine)        \
  201.         (SICompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSICompletionProcInfo, GetCurrentArchitecture())
  202. #else
  203. #define NewSIInterruptProc(userRoutine)        \
  204.         ((SIInterruptUPP) (userRoutine))
  205. #define NewSICompletionProc(userRoutine)        \
  206.         ((SICompletionUPP) (userRoutine))
  207. #endif
  208.  
  209. #if GENERATINGCFM
  210. #define CallSIInterruptProc(userRoutine, inParamPtr, dataBuffer, peakAmplitude, sampleSize)        \
  211.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSIInterruptProcInfo, (inParamPtr), (dataBuffer), (peakAmplitude), (sampleSize))
  212. #define CallSICompletionProc(userRoutine, inParamPtr)        \
  213.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSICompletionProcInfo, (inParamPtr))
  214. #else
  215. /* (*SIInterruptProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  216. #define CallSICompletionProc(userRoutine, inParamPtr)        \
  217.         (*(userRoutine))((inParamPtr))
  218. #endif
  219.  
  220.  
  221. #ifdef __CFM68K__
  222. #pragma lib_export off
  223. #endif
  224.  
  225. #if GENERATINGPOWERPC
  226. #pragma options align=reset
  227. #endif
  228.  
  229. #ifdef __cplusplus
  230. }
  231. #endif
  232.  
  233. #endif /* __SOUNDINPUT__ */
  234.